#!/bin/sh
#
# build -- Build the docker image for the lab
#
# Copyright (C) 2016-2021 Wu Zhangjin <falcon@ruma.tech>
#
# ref: https://docs.docker.com/engine/installation/linux/ubuntulinux/
#
# E.g. LAB_CACHE=0 tools/docer/build
#

TOP_DIR="$(cd "$(dirname "$0")"/../../ && pwd)"
. "$TOP_DIR"/tools/docker/config >/dev/null

[ -n "$LAB_CACHE" -a "x$LAB_CACHE" = "x0"  ] && NO_CACHE="--no-cache"

[ -z "$CURRENT" ] && err_print "Usage: $0 LAB_NAME" && exit 1

get_var PLATFORM
# For cross platform support
[ -n "$PLATFORM" ] && platform="--platform $PLATFORM"

do_op "docker build $NO_CACHE $platform -t " IMAGE "'$CONFIG_DIR'"
